function makeArea(shape: Shape) {
  return shape.getArea()
}

abstract class Shape {
  abstract getArea(): number   //没有实现体   --抽象方法必须放在抽象类里面 抽象类里面的方法必须被子类实现
}

class Rectangle extends Shape{
  private width: number
  private height: number

  constructor(width: number, height: number) {
    super()
    this.width = width;
    this.height = height
  }

  getArea() {
    return this.width * this.height
  }
}

class Circle extends Shape{
  private r: number

  constructor(r: number) {
    super()
    this.r = r
  }

  getArea() {
    return this.r * this.r * 3.14
  }
}

const rectangle = new Rectangle(10, 20)
const circle = new Circle(10)

console.log(makeArea(rectangle));
console.log(makeArea(circle));

//加上 Shape限制 就不能乱传了
// makeArea("dsadsa")
// makeArea(15515)
// class dsadsa {}
// makeArea(new dsadsa())


export {}